package com.prs.crm.dao.cqunicom.impl;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.cqunicom.NewsSendContentDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.cqunicom.NewsSendContent;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-3-3 上午10:14:39
 * 简单说明
 */

public class NewsSendContentDaoImpl extends BaseDaoImpl<NewsSendContent>
		implements NewsSendContentDao {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public int getBackSendContent(final String sendTitle) {
		 return (Integer) this.getHibernateTemplate().execute(
					new HibernateCallback()
					{
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(NewsSendContent.class);
				        	criteria.add(Restrictions.eq("newsTitle",sendTitle));				        	
							return criteria.list().size();
				 				        	
				        }
					}
			);
	}

	@Override
	public Integer delNewsSendContent() {
		return (Integer) this.getHibernateTemplate().execute(
			      new HibernateCallback() {   
						public Object doInHibernate(Session session) throws HibernateException {
							Query query = session.createQuery("delete from NewsSendContent");
							return query.executeUpdate();
				        }   
				 } );
	}

}
